<?php

class FileLog
{

  /**
   * The open file handle.
   *
   * @access private
   */

  var $theFileName="/tmp/log_file.txt";
  var $m_handle;


  	function FileLog()
	{
	  if (file_exists($this->theFileName))
		{
	  	$this->m_handle = @fopen($this->theFileName, 'a') ;
		}
	  	else
		{
		$this->m_handle = @fopen($this->theFileName, 'w') ;
		}	
	  	if ($this->m_handle == FALSE)
		{
	  	trigger_error('Failed to open log file: ' . $this->theFileName . '\n' .
			'Current working directory: ' . getcwd(), E_USER_WARNING) ;
		} 
    }

	function close()
	{
		if ($this->m_handle != FALSE)
		{
			fclose($this->m_handle) ;
		}
	}

  
	function writeLog($val)
	{
		$theData=date('[d-m-Y H:i:s]')." ".$val."\n";
		echo "$theData";
		if ($this->m_handle != FALSE)
		{
			return fwrite($this->m_handle, $theData) ;
		}
	}
}
?>